<?php
defined('ACCESS') or die('Restricted Access');
class Login
{
    public $cmd;
    function run()
    {
        if(UserCurrent::$current->data == false)
        {
            return $this->login();
        }
        $this->cmd = ObjInput::get('cmd','str','');
        if($this->cmd == 'signout')
        {
            UserCurrent::logOut();
            Url::redirectUrl();
        }       
        echo "<script>
                    window.location = '?master=admin&page=dashboard';
                </script>";             
    }   
    function login()
    {
        skn()->set_file('backend/login.html');
        $do = ObjInput::get('do','str','');
        $msg = '';
        if($do == 'submit')
        {
            require_once 'includes'.DS.'user.login.php';            
            $userName = ObjInput::get('username','str','');
            $password = ObjInput::get('password','str','');
            $checkLogin = UserLogin::login($userName,$password);
            if($checkLogin =='SUCCESS')
            {
                echo "<script>
                    window.location = '?portal=admin&page=home';
                </script>";  
            }
            else
                $msg = '<span class="message information">Đăng nhập không thành công!</strong></span>';           
        }        
        skn()->set_var('action',Url::buildUrl(array('do' => 'submit'),'admin','login'));
//        skn()->set_var('msg',$msg);
        $html = skn()->output();      
    }  
    
}
$obj = new Login();
$html = $obj->run();
echo $html;
?>